<%@page contentType="application/vnd.google-earth.kml+xml"%><%@page pageEncoding="UTF-8"%><?xml version="1.0" encoding="UTF-8"?>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/taglib/wms2kml" prefix="wms2kml"%>
<%--
Displays a region and provides network links for sub-regions.  This is called 
from the RegionBasedOverlay tag.

Data passed in:
   wmsURL: URL to GetMap operation, not including bounding box, including trailing ampersand
   callbackURL: URL for callbacks to this server (String)
   dbox: Bounding box for this region (double[4])
   regionDboxes: Bounding boxes for each sub-region (LatLonBoundingBox[4])
--%>
<kml xmlns="http://earth.google.com/kml/2.2"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://earth.google.com/kml/2.2 http://code.google.com/apis/kml/schema/kml22beta.xsd">
    <Document>
        <GroundOverlay>
            <drawOrder>1</drawOrder>
            <Icon>
                <href>${wmsURL}BBOX=${dbox[0]},${dbox[1]},${dbox[2]},${dbox[3]}</href>
            </Icon>
            <LatLonBox>
                <north>${dbox[3]}</north>
                <south>${dbox[1]}</south>
                <east>${dbox[2]}</east>
                <west>${dbox[0]}</west>
            </LatLonBox>
        </GroundOverlay>
        <%-- Now for the NetworkLinks covering all sub-regions --%>
        <c:forEach items="${regionDboxes}" var="regionDbox">
            <NetworkLink>
                <visibility>1</visibility>
                <Region>
                    <LatLonAltBox>
                        <north>${regionDbox.northLat}</north>
                        <south>${regionDbox.southLat}</south>
                        <east>${regionDbox.eastLon}</east>
                        <west>${regionDbox.westLon}</west>
                    </LatLonAltBox>
                    <Lod>
                        <minLodPixels>380</minLodPixels>
                        <maxLodPixels>-1</maxLodPixels>
                    </Lod>
                </Region>
                <Link>
                    <viewRefreshMode>onRegion</viewRefreshMode>
                    <href>${callbackURL}?URL=${wmsURL}&amp;DBOX=${regionDbox.westLon},${regionDbox.southLat},${regionDbox.eastLon},${regionDbox.northLat}</href>
                </Link>
            </NetworkLink>
        </c:forEach>
    </Document>
</kml>
